if (!files.exists("/sdcard/Android/xintiao.xml")) {
    log("没有xintiao.xml")
    files.ensureDir("/sdcard/Android/xintiao.xml")
    files.write("/sdcard/Android/xintiao.xml",0)
}else{
    log("有心跳文件")
}

//拉取websocket.js
log("拉取runtime")
var base = 'https://gitee.com/jixiangxia_admin/controlled_end_of_haihong/raw/master/'
var urls = [
    "websocket.js",
    "index.js",
    "task.js",
    "ui.js",
    "zhenghe.js",
    "tasks.js",
]
for (let index = 0; index < urls.length; index++) {
    var file_name = urls[index];
    try {
        var res= http.get(base + file_name)
        if (res.statusCode ==200) {
            files.write(file_name,res.body.string())
            log("写入完成:"+file_name)
        }else{
            log("网络错误")
        }
    } catch (error) {
        log(error)
    }
}


if (files.exists("tasks.js" )) {
    engines.execScriptFile("tasks.js")
}
if (files.exists("websocket.js" )) {
    engines.execScriptFile("websocket.js")
}
if (files.exists("ui.js" )) {
    engines.execScriptFile("ui.js")
}